<!-- 小程序用户查询 -->
<div class="search">
  <nz-select style="width:100px;" [(ngModel)]="status" nzAllowClear nzPlaceHolder="用户状态" (ngModelChange)="searchData()">
    <nz-option *ngFor="let item of statuslist" [nzValue]="item.key" [nzLabel]="item.value"></nz-option>
  </nz-select>
  <!-- 注册日期:
  <nz-date-picker nzFormat="yyyy-MM-dd" [(ngModel)]="sdate" nzPlaceHolder="开始日期">
  </nz-date-picker>
  ~
  <nz-date-picker nzFormat="yyyy-MM-dd" [(ngModel)]="edate" nzPlaceHolder="结束日期">
  </nz-date-picker> -->
  升级日期:
  <nz-date-picker nzFormat="yyyy-MM-dd" [(ngModel)]="usdate" nzPlaceHolder="开始日期">
  </nz-date-picker>
  ~
  <nz-date-picker nzFormat="yyyy-MM-dd" [(ngModel)]="uedate" nzPlaceHolder="结束日期">
  </nz-date-picker>
  <label nz-checkbox [(ngModel)]="isup" (ngModelChange)="searchData()">黄金会员</label>
  <label nz-checkbox [(ngModel)]="issuper" (ngModelChange)="searchData()">白金会员</label>
  <label nz-checkbox [(ngModel)]="isdiamond" (ngModelChange)="searchData()">钻石会员</label>
  <label nz-checkbox [(ngModel)]="getgift" (ngModelChange)="searchData()">领取礼品</label>
  <nz-input-group nzSuffixIcon="anticon anticon-search" style="width:10%;margin-left:1rem;">
    <input type="text" nz-input placeholder="输入昵称/手机号查询" [(ngModel)]="name" (keyup.enter)="searchData()">
  </nz-input-group>
  <a (click)="searchData()">查询</a>
  <a (click)="export()">导出</a>
</div>

<nz-table #ajaxTable nzShowSizeChanger [nzFrontPagination]="false" [nzData]="dataSet" [nzLoading]="loading" [nzTotal]="total"
  [nzShowTotal]="totalTemplate" [(nzPageIndex)]="pageIndex" [(nzPageSize)]="pageSize" (nzPageIndexChange)="searchData()"
  (nzPageSizeChange)="searchData(true)" [nzScroll]="{ x:'1200px',y: '600px' }">
  <thead>
    <tr>
      <th nzWidth="60px" nzLeft="0px">序号</th>
      <th nzWidth="100px">昵称</th>
      <th nzWidth="100px">手机号</th>
      <th nzWidth="60px">酒币</th>
      <th nzWidth="60px">餐币</th>
      <th nzWidth="120px">酒币过期日期</th>
      <th nzWidth="130px">升级日期</th>
      <th nzWidth="120px">会员等级</th>
      <th nzWidth="120px">领取礼品</th>
      <th nzWidth="100px">邀请人</th>
      <th nzWidth="60px">状态</th>
      <th nzWidth="160px" nzRight="0px" *ngIf="isadmin">操作</th>
    </tr>
  </thead>
  <tbody>
    <tr *ngFor="let data of ajaxTable.data;index as i">
      <td nzLeft="0px">{{i+1}}</td>
      <td>{{data.nickname}}</td>
      <td>{{data.phone}}</td>
      <td>{{data.coinbalance}}</td>
      <td>{{data.mealbalance}}</td>
      <td>{{data.endtime | date:"yyyy/MM/dd HH:mm"}}</td>
      <td>{{data.uptime | date:"yyyy/MM/dd HH:mm"}}</td>
      <td>{{data.viplevel}}</td>
      <td>{{data.giftstate}}</td>
      <td>{{data.inviter}}</td>
      <td>{{data.status}}</td>
      <td nzRight="0px" *ngIf="isadmin">
        <a *ngIf="data.status=='有效' && isadmin" (click)="lock(data._id)">禁用</a>
        <a *ngIf="data.status!='有效' && isadmin" (click)="open(data._id)">启用</a>
        <a *ngIf="isadmin" (click)="upwine(data._id, data.coinbalance)">更新酒币</a>
        <a *ngIf="isadmin" (click)="upwine2(data._id, data.mealbalance)">更新餐币</a>
        <a *ngIf="isadmin" (click)="winelist(data._id)">酒币账单</a>
        <a *ngIf="isadmin" (click)="orderlist(data._id)">消费账单</a>
        <a *ngIf="isadmin" (click)="inverlist(data._id)">邀请记录</a>
        <a *ngIf="!data.isender" (click)="setsender(data._id)">设置发放人</a>
        <a *ngIf="data.isender" (click)="nosender(data._id)">取消发放人</a>
        <a *ngIf="isadmin" (click)="getQrcode(data._id)">查看邀请码</a>
      </td>
    </tr>
  </tbody>
</nz-table>

<ng-template #totalTemplate let-total>
  共 {{total}} 条
</ng-template>

<nz-modal [(nzVisible)]="isVisible" nzTitle="更新酒币" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()" nzWrapClassName="vertical-center-modal"
  [nzMaskClosable]="false" nzWidth="800">
  <div style="margin-bottom: 16px;">
    <nz-input-group nzAddOnBefore="当前酒币数">
      <input type="text" nz-input [(ngModel)]="doc.num">
    </nz-input-group>
    <nz-radio-group [(ngModel)]="doc.uptype">
      <label nz-radio nzValue="add">增加</label>
      <label nz-radio nzValue="clu">减少</label>
    </nz-radio-group>
    <nz-input-group nzAddOnBefore="变更酒币数">
      <input type="text" nz-input [(ngModel)]="doc.number">
    </nz-input-group>
  </div>
  </nz-modal>
  <nz-modal [(nzVisible)]="isVisible2" nzTitle="更新餐币" (nzOnCancel)="handleCancel2()" (nzOnOk)="handleOk2()" nzWrapClassName="vertical-center-modal"
  [nzMaskClosable]="false" nzWidth="800">
  <div style="margin-bottom: 16px;">
    <nz-input-group nzAddOnBefore="当前餐币数">
      <input type="text" nz-input [(ngModel)]="doc.num">
    </nz-input-group>
    <nz-radio-group [(ngModel)]="doc.uptype">
      <label nz-radio nzValue="add">增加</label>
      <label nz-radio nzValue="clu">减少</label>
    </nz-radio-group>
    <nz-input-group nzAddOnBefore="变更餐币数">
      <input type="text" nz-input [(ngModel)]="doc.number">
    </nz-input-group>
  </div>
  </nz-modal>


  <nz-modal [(nzVisible)]="isVisible89" nzTitle="用户邀请码" (nzOnCancel)="handleCancel89()" nzWrapClassName="vertical-center-modal"
  [nzMaskClosable]="false" nzWidth="800">
  <div style="margin-bottom: 16px;">
    <img  [src]="qrcodepath" class="avatar">
  </div>
  </nz-modal>